package com.dz.finance.wechat.service;


import com.dtflys.forest.annotation.*;
import com.dz.finance.wechat.entity.AccessToken;
import com.dz.finance.wechat.entity.MpQrCodeCreateReq;
import com.dz.finance.wechat.entity.MpQrCodeCreateResp;
import org.springframework.stereotype.Component;

@Component
@Retry(maxRetryCount = "3", maxRetryInterval = "10") // 最大重试次数3次，重试间隔10毫秒
public interface WeChatHttpClient {


    /*
     * 获取微信接口调用凭证
     * 设置@Request注解的async属性为true实现，不设置或设置为false即为同步请求
     * */
    @Get(url = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential")
    AccessToken getAccessToken(@Query("appid") String appId, @Query("secret") String appSecret);


    /*
     * 创建二维码ticket
     * */
    @Post("https://api.weixin.qq.com/cgi-bin/qrcode/create")
    MpQrCodeCreateResp getTicket(@Query("access_token") String accessToken, @JSONBody MpQrCodeCreateReq mReq);

}
